package com.example.yuejian.yuejian.adapter;


import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.example.yuejian.yuejian.R;
import com.example.yuejian.yuejian.bean.Question;

import java.util.List;

/**
 * Created by Administrator on 2017/9/18.
 */

public class QuestionAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
{
    private Context mContext;;
    private List mDataList;
    public LayoutInflater mLayoutInflater;
    public QuestionAdapter(Context mContext, List mDataList){
        this.mContext = mContext;
        this.mDataList = mDataList;
        mLayoutInflater = LayoutInflater.from(mContext);
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View v = mLayoutInflater.inflate(R.layout.cardview_teacher_detail_question, parent, false);
        return new ViewHolder(v);
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        final Question entity = (Question) mDataList.get(position);
        if (null == entity)
            return;
        final ViewHolder viewHolder = (ViewHolder) holder;
        viewHolder.question_name.setText(entity.getUsername());
        viewHolder.question_time.setText(entity.getData());
        viewHolder.question_content.setText(entity.getQcontent());


        /*viewHolder.master_detail.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent=new Intent(mContext, TeacherDetailActivity.class);
                intent.putExtra("master_id",entity.getId()+"");
                mContext.startActivity(intent);

            }
        });*/
    }


    @Override
    public int getItemCount() {
        return mDataList.size();
    }


    public class ViewHolder extends RecyclerView.ViewHolder{
        TextView question_name;

        TextView question_time;
        TextView question_content;

        //ImageView imageView_follow;
        //LinearLayout master_detail;

        public ViewHolder(View itemView) {
            super(itemView);

           question_name = (TextView) itemView.findViewById(R.id.tv_question_username);

            question_time = (TextView) itemView.findViewById(R.id.tv_question_date);
            question_content= (TextView) itemView.findViewById(R.id.tv_question_content);
            //master_detail=(LinearLayout)itemView.findViewById(R.id.cardview_home_teacher_detail);

        }
    }

}
